import { BaseWindow } from "../../../component/window/BaseWindow";
import { ILayer } from "../../../mvc/interfaces/ILayer";
import { Language } from "../../../../extend/language/Language";
import { ObjCreate } from "../common/ObjCreate";
import { ItemData } from "../../resource/info/ItemData";
import { ClickToShowItemTip } from "../common/tooltip/ClickToShowItemTip";
//class TeamBuyRuleView
    
    export  class TeamBuyRuleView extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            this.setSize(320, 330);
            titleHeight = 27;
            this.title = Language.getString(85030);
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            ObjCreate.createFlowerBg(16, 37, 288, 283, this, true);
            this._contentTxt = ObjCreate.createTextField("", 32, 61, 259, 500, this, null, true);
            this._contentTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._contentTxt.mouseWheelEnabled = false;
            var loc2;
            this._contentTxt.wordWrap = loc2 = true;
            this._contentTxt.multiline = loc2;
            this._contentTxt.addEventListener(flash.events.TextEvent.LINK, this.linkHander);
            var loc1=Language.getString(85025);
            this.updateContent(loc1);
            return;
        }

        public updateContent(arg1: string): void
        {
            var loc3=null;
            var loc4=NaN;
            var loc5=null;
            var loc1=arg1.match(new RegExp("\\{\\d+\\}", "g"));
            var loc2=0;
            while (loc2 < loc1.length) 
            {
                loc3 = loc1[loc2];
                loc4 = Number(loc3.substring(1, (loc3.length - 1)));
                loc5 = new ItemData(loc4);
                arg1 = arg1.replace(loc3, "<u><a href=\'event:" + loc4 + "\'>" + loc5.itemInfo.htmlName + "</a></u>");
                ++loc2;
            }
            this._contentTxt.htmlText = arg1;
            return;
        }

        /* internal  */linkHander(arg1: Object /* flash.events.TextEvent */): void
        {
            var loc1=int(arg1.text);
            this._isItemTip = true;
            ClickToShowItemTip.instance.setItemCodeAndShow(loc1);
            return;
        }

        public /* override */ hide(): void
        {
            if (this._isItemTip) 
            {
                this._isItemTip = false;
                ClickToShowItemTip.instance.hide();
            }
            super.hide();
            return;
        }

        /* internal */ /* var */_contentTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_isItemTip: Boolean=false;
    }
